/**
* @ClassName: CredentialsServiceImpl
* @Description: 
* @author YuYang
* @date 2013-6-5 上午12:51:45
*/
package com.demodis.service.impl;

import java.util.List;

import com.demodis.dao.CredentialsDaoI;
import com.demodis.dao.impl.CredentialsDaoImpl;
import com.demodis.domain.TblCredentials;
import com.demodis.service.CredentialsServiceI;
import com.demodis.util.Utils;

public class CredentialsServiceImpl implements CredentialsServiceI {
	
	private CredentialsDaoI creDao = new CredentialsDaoImpl();

	@Override
	public boolean save(TblCredentials t) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean delete(TblCredentials t) {
		return creDao.delete(t);
	}

	@Override
	public boolean modify(TblCredentials t) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Object get() {
		return null;
	}

	@Override
	public boolean save(TblCredentials t, String realPath) {
		for (int i = 0; i < t.getImgsFileName().length; i++) {
			t.setFileName(Utils.saveFile(t.getImgs()[i], t.getImgsFileName()[i], realPath));
			
			creDao.save(t);
		}
		return true;
	}

	@Override
	public List<TblCredentials> get(TblCredentials cre) {
		return creDao.get(cre);
	}

	@Override
	public boolean modify(TblCredentials t, String realPath) {
		t.setFileName(Utils.saveFile(t.getImgs()[0], t.getImgsFileName()[0], realPath));
		
		return creDao.modify(t);
	}

}
